namespace DotNetNuke.UI.UserControls
{
    using DotNetNuke.Framework;
    using DotNetNuke.Services.Exceptions;
    using DotNetNuke.Services.Localization;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Runtime.CompilerServices;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    /// -----------------------------------------------------------------------------
    /// <summary>
    /// The User UserControl is used to manage User Details
    /// </summary>
    /// <remarks>
    /// </remarks>
    /// <history>
    /// [cnurse]	02/21/2005	created
    /// </history>
    /// -----------------------------------------------------------------------------
    public class User : UserControlBase
    {
        private static List<WeakReference> __ENCList = new List<WeakReference>();
        private string _Confirm;
        //("ConfirmPasswordRow")]
        private HtmlTableRow _ConfirmPasswordRow;
        private string _ControlColumnWidth;
        private string _Email;
        private string _FirstName;
        private string _IM;
        private string _LabelColumnWidth;
        private string _LastName;
        //("lblUsername")]
        private Label _lblUsername;
        //("lblUsernameAsterisk")]
        private Label _lblUsernameAsterisk;
        private int _ModuleId;
        private string _Password;
        //("PasswordRow")]
        private HtmlTableRow _PasswordRow;
        private bool _ShowPassword;
        private int _StartTabIndex;
        //("txtConfirm")]
        private TextBox _txtConfirm;
        //("txtEmail")]
        private TextBox _txtEmail;
        //("txtFirstName")]
        private TextBox _txtFirstName;
        //("txtIM")]
        private TextBox _txtIM;
        //("txtLastName")]
        private TextBox _txtLastName;
        //("txtPassword")]
        private TextBox _txtPassword;
        //("txtUsername")]
        private TextBox _txtUsername;
        //("txtWebsite")]
        private TextBox _txtWebsite;
        private string _UserName;
        //("valConfirm1")]
        private RequiredFieldValidator _valConfirm1;
        //("valConfirm2")]
        private CompareValidator _valConfirm2;
        //("valEmail1")]
        private RequiredFieldValidator _valEmail1;
        //("valEmail2")]
        private RegularExpressionValidator _valEmail2;
        //("valFirstName")]
        private RequiredFieldValidator _valFirstName;
        //("valLastName")]
        private RequiredFieldValidator _valLastName;
        //("valPassword")]
        private RequiredFieldValidator _valPassword;
        //("valUsername")]
        private RequiredFieldValidator _valUsername;
        private string _Website;
        private string MyFileName;
        protected LabelControl plConfirm;
        protected LabelControl plEmail;
        protected LabelControl plFirstName;
        protected LabelControl plIM;
        protected LabelControl plLastName;
        protected LabelControl plPassword;
        protected LabelControl plUserName;
        protected LabelControl plWebsite;

        public User()
        {
            base.Load += new EventHandler(this.Page_Load);
            base.Init += new EventHandler(this.Page_Init);
            List<WeakReference> refObjectHelperL0 = __ENCList;
            lock (refObjectHelperL0)
            {
                __ENCList.Add(new WeakReference(this));
            }
            this._LabelColumnWidth = "";
            this._ControlColumnWidth = "";
            this._StartTabIndex = 1;
            this.MyFileName = "User.ascx";
        }

        [DebuggerStepThrough]
        private void InitializeComponent()
        {
        }

        private void Page_Init(object sender, EventArgs e)
        {
            this.InitializeComponent();
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// [cnurse]	02/21/2005	created
        /// </history>
        /// -----------------------------------------------------------------------------
        private void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!this.Page.IsPostBack)
                {
                    this.txtFirstName.TabIndex = Convert.ToInt16(this._StartTabIndex);
                    this.txtLastName.TabIndex = Convert.ToInt16((int) (this._StartTabIndex + 1));
                    this.txtUsername.TabIndex = Convert.ToInt16((int) (this._StartTabIndex + 2));
                    this.txtPassword.TabIndex = Convert.ToInt16((int) (this._StartTabIndex + 3));
                    this.txtConfirm.TabIndex = Convert.ToInt16((int) (this._StartTabIndex + 4));
                    this.txtEmail.TabIndex = Convert.ToInt16((int) (this._StartTabIndex + 5));
                    this.txtWebsite.TabIndex = Convert.ToInt16((int) (this._StartTabIndex + 6));
                    this.txtIM.TabIndex = Convert.ToInt16((int) (this._StartTabIndex + 7));
                    this.txtFirstName.Text = this._FirstName;
                    this.txtLastName.Text = this._LastName;
                    this.txtUsername.Text = this._UserName;
                    this.lblUsername.Text = this._UserName;
                    this.txtPassword.Text = this._Password;
                    this.txtConfirm.Text = this._Confirm;
                    this.txtEmail.Text = this._Email;
                    this.txtWebsite.Text = this._Website;
                    this.txtIM.Text = this._IM;
                    if (this._ControlColumnWidth != "")
                    {
                        this.txtFirstName.Width = Unit.Parse(this._ControlColumnWidth);
                        this.txtLastName.Width = Unit.Parse(this._ControlColumnWidth);
                        this.txtUsername.Width = Unit.Parse(this._ControlColumnWidth);
                        this.txtPassword.Width = Unit.Parse(this._ControlColumnWidth);
                        this.txtConfirm.Width = Unit.Parse(this._ControlColumnWidth);
                        this.txtEmail.Width = Unit.Parse(this._ControlColumnWidth);
                        this.txtWebsite.Width = Unit.Parse(this._ControlColumnWidth);
                        this.txtIM.Width = Unit.Parse(this._ControlColumnWidth);
                    }
                    if (!this._ShowPassword)
                    {
                        this.valPassword.Enabled = false;
                        this.valConfirm1.Enabled = false;
                        this.valConfirm2.Enabled = false;
                        this.PasswordRow.Visible = false;
                        this.ConfirmPasswordRow.Visible = false;
                        this.txtUsername.Visible = false;
                        this.valUsername.Enabled = false;
                        this.lblUsername.Visible = true;
                        this.lblUsernameAsterisk.Visible = false;
                    }
                    else
                    {
                        this.txtUsername.Visible = true;
                        this.valUsername.Enabled = true;
                        this.lblUsername.Visible = false;
                        this.lblUsernameAsterisk.Visible = true;
                        this.valPassword.Enabled = true;
                        this.valConfirm1.Enabled = true;
                        this.valConfirm2.Enabled = true;
                        this.PasswordRow.Visible = true;
                        this.ConfirmPasswordRow.Visible = true;
                    }
                    this.ViewState["ModuleId"] = Convert.ToString(this._ModuleId);
                    this.ViewState["LabelColumnWidth"] = this._LabelColumnWidth;
                    this.ViewState["ControlColumnWidth"] = this._ControlColumnWidth;
                }
                this.txtPassword.Attributes.Add("value", this.txtPassword.Text);
                this.txtConfirm.Attributes.Add("value", this.txtConfirm.Text);
            }
            catch (Exception exception1)
            {
                
                Exception exc = exception1;
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc);
                
            }
        }

        public string Confirm
        {
            get
            {
                return this.txtConfirm.Text;
            }
            set
            {
                this._Confirm = value;
            }
        }

        protected virtual HtmlTableRow ConfirmPasswordRow
        {
           
            get
            {
                return this._ConfirmPasswordRow;
            }
            
            set
            {
                this._ConfirmPasswordRow = value;
            }
        }

        public string ControlColumnWidth
        {
            get
            {
                return Convert.ToString(RuntimeHelpers.GetObjectValue(this.ViewState["ControlColumnWidth"]));
            }
            set
            {
                this._ControlColumnWidth = value;
            }
        }

        public string Email
        {
            get
            {
                return this.txtEmail.Text;
            }
            set
            {
                this._Email = value;
            }
        }

        public string FirstName
        {
            get
            {
                return this.txtFirstName.Text;
            }
            set
            {
                this._FirstName = value;
            }
        }

        public string IM
        {
            get
            {
                return this.txtIM.Text;
            }
            set
            {
                this._IM = value;
            }
        }

        public string LabelColumnWidth
        {
            get
            {
                return Convert.ToString(RuntimeHelpers.GetObjectValue(this.ViewState["LabelColumnWidth"]));
            }
            set
            {
                this._LabelColumnWidth = value;
            }
        }

        public string LastName
        {
            get
            {
                return this.txtLastName.Text;
            }
            set
            {
                this._LastName = value;
            }
        }

        protected virtual Label lblUsername
        {
           
            get
            {
                return this._lblUsername;
            }
            
            set
            {
                this._lblUsername = value;
            }
        }

        protected virtual Label lblUsernameAsterisk
        {
           
            get
            {
                return this._lblUsernameAsterisk;
            }
            
            set
            {
                this._lblUsernameAsterisk = value;
            }
        }

        public string LocalResourceFile
        {
            get
            {
                return DotNetNuke.Services.Localization.Localization.GetResourceFile(this, this.MyFileName);
            }
        }

        public int ModuleId
        {
            get
            {
                return Convert.ToInt32(RuntimeHelpers.GetObjectValue(this.ViewState["ModuleId"]));
            }
            set
            {
                this._ModuleId = value;
            }
        }

        public string Password
        {
            get
            {
                return this.txtPassword.Text;
            }
            set
            {
                this._Password = value;
            }
        }

        protected virtual HtmlTableRow PasswordRow
        {
           
            get
            {
                return this._PasswordRow;
            }
            
            set
            {
                this._PasswordRow = value;
            }
        }

        public bool ShowPassword
        {
            set
            {
                this._ShowPassword = value;
            }
        }

        public int StartTabIndex
        {
            set
            {
                this._StartTabIndex = value;
            }
        }

        protected virtual TextBox txtConfirm
        {
           
            get
            {
                return this._txtConfirm;
            }
            
            set
            {
                this._txtConfirm = value;
            }
        }

        protected virtual TextBox txtEmail
        {
           
            get
            {
                return this._txtEmail;
            }
            
            set
            {
                this._txtEmail = value;
            }
        }

        protected virtual TextBox txtFirstName
        {
           
            get
            {
                return this._txtFirstName;
            }
            
            set
            {
                this._txtFirstName = value;
            }
        }

        protected virtual TextBox txtIM
        {
           
            get
            {
                return this._txtIM;
            }
            
            set
            {
                this._txtIM = value;
            }
        }

        protected virtual TextBox txtLastName
        {
           
            get
            {
                return this._txtLastName;
            }
            
            set
            {
                this._txtLastName = value;
            }
        }

        protected virtual TextBox txtPassword
        {
           
            get
            {
                return this._txtPassword;
            }
            
            set
            {
                this._txtPassword = value;
            }
        }

        protected virtual TextBox txtUsername
        {
           
            get
            {
                return this._txtUsername;
            }
            
            set
            {
                this._txtUsername = value;
            }
        }

        protected virtual TextBox txtWebsite
        {
           
            get
            {
                return this._txtWebsite;
            }
            
            set
            {
                this._txtWebsite = value;
            }
        }

        public string UserName
        {
            get
            {
                return this.txtUsername.Text;
            }
            set
            {
                this._UserName = value;
            }
        }

        protected virtual RequiredFieldValidator valConfirm1
        {
           
            get
            {
                return this._valConfirm1;
            }
            
            set
            {
                this._valConfirm1 = value;
            }
        }

        protected virtual CompareValidator valConfirm2
        {
           
            get
            {
                return this._valConfirm2;
            }
            
            set
            {
                this._valConfirm2 = value;
            }
        }

        protected virtual RequiredFieldValidator valEmail1
        {
           
            get
            {
                return this._valEmail1;
            }
            
            set
            {
                this._valEmail1 = value;
            }
        }

        protected virtual RegularExpressionValidator valEmail2
        {
           
            get
            {
                return this._valEmail2;
            }
            
            set
            {
                this._valEmail2 = value;
            }
        }

        protected virtual RequiredFieldValidator valFirstName
        {
           
            get
            {
                return this._valFirstName;
            }
            
            set
            {
                this._valFirstName = value;
            }
        }

        protected virtual RequiredFieldValidator valLastName
        {
           
            get
            {
                return this._valLastName;
            }
            
            set
            {
                this._valLastName = value;
            }
        }

        protected virtual RequiredFieldValidator valPassword
        {
           
            get
            {
                return this._valPassword;
            }
            
            set
            {
                this._valPassword = value;
            }
        }

        protected virtual RequiredFieldValidator valUsername
        {
           
            get
            {
                return this._valUsername;
            }
            
            set
            {
                this._valUsername = value;
            }
        }

        public string Website
        {
            get
            {
                return this.txtWebsite.Text;
            }
            set
            {
                this._Website = value;
            }
        }
    }
}

